UILoader

Kind of class:class
Inherits from:UIComponent < MovieClip
Classpath:gfx.controls.UILoader
File last modified:Tuesday, 29 June 2010, 09:03:27
The CLIK UILoader loads an external SWF/GFX or image using only the path. UILoaders also support auto-sizing of the loaded asset to fit in its bounding box. Asset loading is asynchronous if both GFx and the platform running it has threading support.

Inspectable Properties
A MovieClip that derives from the UILoader component will have the following inspectable properties:
  • visible: Hides the component if set to false.
  • autoSize: If set to true, sizes the loaded to content to fit in the UILoader’s bounds.
  • maintainAspectRatio: If true, the loaded content will be fit based on its aspect ratio inside the UILoader’s bounds. If false, then the content will be stretched to fit the UILoader bounds.
  • source: The SWF/GFX or image filename to load.
  • enableInitCallback: If set to true, _global.CLIK_loadCallback() will be fired when a component is loaded and _global.CLIK_unloadCallback will be called when the component is unloaded. These methods receive the instance name, target path, and a reference the component as parameters. _global.CLIK_loadCallback and _global.CLIK_unloadCallback should be overriden from the game engine using GFx FunctionObjects.
States
There are no states for the UILoader component. If a SWF/GFX is loaded into the UILoader, then it may have its own states.

Events
All event callbacks receive a single Object parameter that contains relevant information about the event. The following properties are common to all events.
  • type: The event type.
  • target: The target that generated the event.
The events generated by the UILoader component are listed below. The properties listed next to the event are provided in addition to the common properties.
  • show: The component’s visible property has been set to true at runtime.
  • hide: The component’s visible property has been set to false at runtime.
  • progress: Content is in the process of being loaded regardless whether the content can or cannot be loaded. This event will be fired continuously until either a) the content is loaded or b) the loading timeout has been reached.
    • loaded: The percentage of data loaded. This property’s value is between 0 and 100.
  • complete: Content loading has been completed.
  • ioError: Content specified in the source property could not be loaded.
Component metadata:
    InspectableList
    "autoSize"
    "enableInitCallback"
    "maintainAspectRatio"
    "source"
    "visible"

    Summary


    Constructor
    Instance properties
    • bytesLoaded
      • The total bytes loaded in the current load
    • bytesTotal
      • The current total bytes in the current load.
    • autoSize
      • Automatically scale the content to fit the container.
    • source
      • Set the source of the content to be loaded.
    • maintainAspectRatio
      • Maintain the original content's aspect ration when scaling it.
    • content
      • A read-only property that returns the loaded content of the UILoader.
    • percentLoaded
      • A read-only property that returns the percentage that the content is loaded.
    Class methods
    Class methods inherited from UIComponent
    Instance methods
    • unload
      • Unload the currently loaded content, or stop any pending or active load.

    Constructor

    UILoader

    function UILoader (
    )

    The constructor is called when a UILoader or a sub-class of UILoader is instantiated on stage or by using attachMovie() in ActionScript. This component can not be instantiated using new syntax. When creating new components that extend UILoader, ensure that a super() call is made first in the constructor.

    Instance properties

    autoSize

    autoSize:Boolean
    (read,write)

    Automatically scale the content to fit the container.

    bytesLoaded

    bytesLoaded:Number
    (read,write)

    The total bytes loaded in the current load

    bytesTotal

    bytesTotal:Number
    (read,write)

    The current total bytes in the current load.

    content

    content:MovieClip
    (read)

    A read-only property that returns the loaded content of the UILoader.

    maintainAspectRatio

    maintainAspectRatio:Boolean
    (read,write)

    Maintain the original content's aspect ration when scaling it. If autoSize is false, this property is ignored.

    percentLoaded

    percentLoaded:Number
    (read)

    A read-only property that returns the percentage that the content is loaded. The percentage is normalized to a 0-100 range.

    source

    source:String
    (read,write)

    Set the source of the content to be loaded.

    Instance methods

    unload

    function unload (
    ) : Void

    Unload the currently loaded content, or stop any pending or active load.